home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10221 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: noc.netcom.net!usenet
  2. From: Tarang Deshpande <tarang@willows.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: ?Help - struct array of strings
  5. Date: Fri, 15 Mar 1996 17:00:55 -0800
  6. Organization: NETCOM Network Operations
  7. Message-ID: <314A12C7.21E0@willows.com>
  8. References: <4hvpgp$gu7@ftp.netgate.net>
  9. NNTP-Posting-Host: daffy.willows.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
  14.  
  15. Tamara Johnson wrote:
  16. > for(i=0;i<MAX;i++)
  17. >   {
  18. >   printf("Enter author name (ENTER to quit); ");
  19. >   gets(cat[i].name);
  20. >   if(!*cat[i].name) break;
  21. >   printf("Enter title: ");
  22. >   gets(cat[i].title);
  23. >   }
  24. > for(i=0;i<MAX;i++)
  25. >   printf("%c %c\n", cat[i].name, cat[i].title);
  26.  
  27.  
  28.  
  29.  
  30. This is happening because cat[i].name is a pointer and not a character
  31. as you have spcified in your printf format string.  If you actually
  32. mean to output the character then change cat[i].name to *cat[i].name.
  33. If on the other hand you mean to output the string then change the
  34. format string to "%s %s\n" instead.
  35.  
  36.  
  37. Tarang
  38.